import {combineReducers, configureStore} from "@reduxjs/toolkit";
import basicInfoReducer from './basic-info/basicInfo.slice'
import eduExperienceReducer from "./educational-experience/edu-experience.slice";
import jobIntentReducer from './job-intent/job-intent.slice'
import citySlice from './dropdownData/drp-city.slice'
import workInfoReducer from './work-experience/work-experience.slice'
import projectInfoReducer from './project-experience/project-experience.slice'
import skillsReducer from './skill/skill.slice'
import selfEvaluationReducer from './selfAvalution/selfAvalution.slice'
import avatarReducer from './avatar-picture/avatar.slice'
import resumeCenterReducer from './resume-center/resume-center.slice'
import orderReducer from './order/order.slice'
import { persistStore, persistReducer } from 'redux-persist'
import storage from 'redux-persist/lib/storage'

const persistConfig = {
    key: 'root',
    storage,
}

const reducers = combineReducers({
    basic: basicInfoReducer,
    avatar: avatarReducer,
    eduExperience: eduExperienceReducer,
    jobIntent: jobIntentReducer,
    workInfo: workInfoReducer,
    cityList: citySlice,
    projectInfoList: projectInfoReducer,
    skills: skillsReducer,
    selfEvaluation: selfEvaluationReducer,
    resumeCenter: resumeCenterReducer,
    order: orderReducer
})

export const rootStore = configureStore({
    reducer: persistReducer(persistConfig, reducers),
    // middleware: (getDefaultMiddleware) =>
      // getDefaultMiddleware({
          // serializableCheck: {
          //     ignoredActions: ['persist/PERSIST']
          // }
      // }),
    devTools: true

})

export const pStore = persistStore(rootStore)

export type RootState = ReturnType<typeof rootStore.getState>
export type AppDispatch = typeof rootStore.dispatch
